package com.zlx.guguanjia.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zlx.guguanjia.entity.SysResource;
import com.zlx.guguanjia.mapper.SysResourceMapper;
import com.zlx.guguanjia.service.SysResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @ClassName SysResourceServiceImpl
 * @Description TODO
 * @Author Edward
 * @Date 2020/11/4 22:32
 */
@Transactional
@Service
public class SysResourceServiceImpl extends BaseServiceImpl<SysResource,Long> implements SysResourceService {
    @Autowired
    private SysResourceMapper mapper;

    @Override
    public List<SysResource> selectResourceByRid(Long rid) {
        return mapper.selectResourceByRid(rid);
    }

    @Override
    public List<SysResource> selctByUid(Long uid) {
        return mapper.selctByUid(uid);
    }

    @Override
    @Cacheable(cacheNames = "SysResource",key = "'com.zlx.guguanjia.service.impl.SysResourceServiceImpl:selectResource'")
    public List<SysResource> selectResource() {
        return mapper.selectResource();
    }


    /***
     * @Author 周罗校
     * @Description 筛选父级菜单
     * @Param []
     * @return java.util.List<com.zlx.guguanjia.entity.SysResource>
     * @Date 2020.11.06 17:14:38
     **/
    @Override
    public List<SysResource> selectParentMenuSources() {
        return mapper.selectParentMenuSources();
    }

    @Override
    public PageInfo<SysResource> selectMenuSources(int start,int pageSize,Map<String, Object> map) {
        PageHelper.startPage(start,pageSize);
        return new PageInfo<>(mapper.selectMenuSources(map));
    }
}
